package com.jn.principle.singleresponsibility;

/**
 * @author 江南大学1033190417
 * @date 2022/4/9 20:17
 */
public class SingleResponsibility2 {
    public static void main(String[] args) {
        RoadVehicle vehicle1=new RoadVehicle();
        vehicle1.run("汽车");

        AirVehicle vehicle2=new AirVehicle();
        vehicle2.run("飞机");

        WaterVehicle vehicle3=new WaterVehicle();
        vehicle3.run("轮船");
    }

}
//方案2
/*

   1、遵循单一职责
   2、改动很大，将类分解，同时修改客户端
   3、直接修改Vehicle类
 */

class RoadVehicle{
    public void run(String vehicle){
        System.out.println(vehicle+"在公路运行");
    }
}
class AirVehicle{
    public void run(String vehicle){
        System.out.println(vehicle+"在天空运行");
    }
}

class WaterVehicle{
    public void run(String vehicle){
        System.out.println(vehicle+"在水中运行");
    }
}

